#include ".\allegro\include\allegro.h"
#include <iostream>

#include "Vector2D.h"
#include "LibraryInterface.h"
#include "Rectangle.h"

#define MINIMUM_NODE_SIZE 64


class QuadTree
{
	public:
		QuadTree* branches[4];
		Rectangle areaAssignedToNode;

	
		bool leaf;	//is this a leaf?

	public:

		

		QuadTree();
		~QuadTree();

		void SetNodeCenter(unsigned int x, unsigned int y);	//world size encompased by the quadtree
		void SetNodeDimensions(unsigned int w, unsigned int h);
		virtual void DivideLeafNode();
        void DivideLeaves();
		void UniteLeafNodes();
		virtual void RenderQuadTree();
		bool IsLeaf();
		void DestroyChildNodes();	//destroy all nodes below this one

        QuadTree* GetNodeAtPoint(unsigned int x, unsigned int y);
		bool PointIsInsideNode(unsigned int x, unsigned int y);
        QuadTree* GetNodeSurroundingRectangle(Rectangle* rect);

        unsigned int GetX();
        unsigned int GetY();
        unsigned int GetW();
        unsigned int GetH();
};
